# Author:Zhang Yu
import socket
client = socket.socket()
client.connect(("127.0.0.1",9999))

while True:
    cmd = input(">>:").strip()
    if cmd:
        client.send(cmd.encode("utf-8"))
        cmd_res_size = client.recv(1024) #接受res的总长度
        client.send(b"ok")
        total_size = 0
        total_data = b''
        while int(cmd_res_size.decode()) != total_size:

            cmd_res = client.recv(1024)
            #print("接收的长度: ", len(cmd_res))
            #print("总长度: ", cmd_res_size)
            total_size += len(cmd_res)
            total_data += cmd_res

        else:
            print(total_data.decode())
    else:
        continue
client.close()